﻿// -----------------------------------------------------------------------
// <copyright file="GameOverState.cs" company="Microsoft">
// TODO: Update copyright text.
// </copyright>
// -----------------------------------------------------------------------

namespace SpaceshipDuel
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Microsoft.Xna.Framework;
    using Microsoft.Xna.Framework.Graphics;

    /// <summary>
    /// TODO: Update summary.
    /// </summary>
    public static class GameOverState
    {
        #region Private fields

        private static WaitTimer wtimer;
        private static int height;

        #endregion private fields

        #region Construction

        static GameOverState()
        {
            wtimer = new WaitTimer(5.0f);
            height = 0;
        }

        #endregion Construction

        #region Public methods

        public static void StartGameOver()
        {
            wtimer.Reset();
            height = 0;
        }

        public static bool GameOverElapsed(GameTime gameTime, int maxHeight)
        {
            try
            {
                height = (int)(maxHeight / 5.0f * wtimer.GetTimeSinceLastCheck());
                return wtimer.IsElapsed(gameTime.ElapsedGameTime.TotalSeconds);
            }
            catch (Exception)
            {
                return true;
            }
        }

        public static void Draw(GraphicsDevice gd, TextureData textureLeft, TextureData textureRight, int widthLeft, int widthRight)
        {
            SpriteBatch spriteBatch = new SpriteBatch(gd);
            spriteBatch.Begin();
            spriteBatch.Draw(textureLeft.texture, new Rectangle(widthLeft / 2 - textureLeft.halfwidth, height, textureLeft.width, textureLeft.height), Color.White);
            spriteBatch.Draw(textureRight.texture, new Rectangle(widthLeft + widthRight / 2 - textureRight.halfwidth, height, textureRight.width, textureRight.height), Color.White);
            spriteBatch.End();
        }

        #endregion Public methods

        #region Private methods



        #endregion private methods
    }
}
